8da69d0b8483a3a63bc57df5d25edf3e5c5e4ad2,carbon/src/main/java/carbon/widget/Toolbar.java,Toolbar,drawChild,#Canvas#View#number#,261
Before Change
float childElevation = shadowView.getElevation() + shadowView.getTranslationZ();
float[] childLocation = new float[]{(child.getLeft() + child.getRight()) / 2, (child.getTop() + child.getBottom()) / 2};
Matrix matrix = carbon.internal.ViewHelper.getMatrix(child);
matrix.mapPoints(childLocation);
int[] location = new int[2];
getLocationOnScreen(location);
float x = childLocation[0] + location[0];
float y = childLocation[1] + location[1];
x -= getRootView().getWidth() / 2;
y += getRootView().getHeight() / 2; // looks nice
float length = (float) Math.sqrt(x * x + y * y);
int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.translate(
x / length * childElevation / 2,
y / length * childElevation / 2);
canvas.translate(
child.getLeft(),
child.getTop());
canvas.concat(matrix);
shadow.draw(canvas, child, paint);
canvas.restoreToCount(saveCount);
}
}
After Change
}
@Override
protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) {
if (!child.isShown())
return super.drawChild(canvas, child, drawingTime);
if (!isInEditMode() && child instanceof ShadowView && Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT_WATCH) {
ShadowView shadowView = (ShadowView) child;
Shadow shadow = shadowView.getShadow();
if (shadow != null) {
paint.setAlpha((int) (ShadowGenerator.ALPHA * ViewHelper.getAlpha(child)));
float childElevation = shadowView.getElevation() + shadowView.getTranslationZ();
int saveCount = canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.translate(0, childElevation / 2);
canvas.translate(child.getLeft(), child.getTop());
Matrix matrix = carbon.internal.ViewHelper.getMatrix(child);
canvas.concat(matrix);
shadow.draw(canvas, child, paint);
canvas.restoreToCount(saveCount);
}
}